package fair.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import fair.pojo.Work;
import fair.mapper.WorkMapper;
import fair.service.IUserService;
import fair.service.IWorkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 作业表 服务实现类
 * </p>
 *
 * @author fair
 * @since 2021-03-04
 */
@Slf4j
@Transactional
@Service(interfaceClass = IWorkService.class, version = "${dubbo.service.core.version}", group = "${dubbo.service.core.group}", retries = -1)
public class WorkServiceImpl extends ServiceImpl<WorkMapper, Work> implements IWorkService {

    @Autowired
    private WorkMapper workMapper;

    @Override
    public Integer insert(Work work) {
        workMapper.insert(work);
        return work.getId();
    }

    @Override
    public List<Work> findWorks(String name) {
        QueryWrapper<Work> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(Work::getTeacherName, name);
        return workMapper.selectList(queryWrapper);
    }
}
